package com.java2104.entity;

import com.fasterxml.jackson.annotation.JsonView;

import java.io.Serializable;
import java.sql.Timestamp;

//Serializable序列化接口，只有实现了这个接口的对象才能够被序列化
public class User implements Serializable {
    //使用这个接口作为@JsonView注解的泛型 则忽略密码
    private  interface  WithioutPasswordView{};
    private  interface  WithPasswordView extends WithioutPasswordView{};
    //使用这个接口作为@JsonView注解的反省 则转换的JSOn会带密码
    @JsonView(WithioutPasswordView.class)
    public String getUsername(){
        return username;
    }
    @JsonView(WithPasswordView.class)
    public String getPassword(){
        return  password;
    }
    private String empno;//员工编号
    private String username;
    private String password;
    private String nickName;// 映射nick_name字段（规则：下划线去掉，后面紧跟的首字母大写）
    private Timestamp lastLogin;// 映射last_login字段
    private int state;
    //在用户类中额外增加一个角色类型的属性
    private Role role;

    public User() {

    }
    //为新增属性添加getter和setter方法

    public String getEmpno() {
        return empno;
    }

    public void setEmpno(String empno) {
        this.empno = empno;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

//    public String getUsername() {
//        return username;
//    }

    public void setUsername(String username) {
        this.username = username;
    }

//    public String getPassword() {
//        return password;
//    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public Timestamp getLastLogin() {
        return lastLogin;
    }

    public void setLastLogin(Timestamp lastLogin) {
        this.lastLogin = lastLogin;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "User{" +
                "empno='" + empno + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", nickName='" + nickName + '\'' +
                ", lastLogin=" + lastLogin +
                ", state=" + state +
                ", role=" + role +
                '}';
    }
}
